#include<stdio.h>
int main()
{
    long long n, ans = 0;
    int x;
    scanf("%d %lld",&x, &n);
    for(int i = 0; i < n; i ++)
    {
        if(x != 6 && x != 7)
            ans += 250;
        if(x == 7) x = 1;
        else x ++;
    }
    printf("%ld\n", ans);
    return 0;
}